//
//  BaseModel.m
//  JKWDStudent
//
//  Created by 学大教育 on 2022/1/7.
//

#import "BaseModel.h"

@implementation BaseModel
#pragma mark - JSON 解析
+(NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{@"ID":@"id"};
}

- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property {
    
    // 根据 type.typeClass 判定类型
    
    if ([property.type.typeClass isKindOfClass:[NSString class]]) {
        
        if (oldValue == nil || [oldValue isKindOfClass:[NSNull class]]) {
            return @"";
        }
        
    } else if ([property.type.typeClass isKindOfClass:[NSNumber class]]) {

        if (oldValue == nil || [oldValue isKindOfClass:[NSNull class]]) {
            return @0;
        }
        
    } else if ([property.type.typeClass isKindOfClass:[NSArray class]]) {
        
        if ([oldValue isKindOfClass:[NSNull class]]) {
            return [NSArray array];
        }
        
    } else if ([property.type.typeClass isKindOfClass:[NSDictionary class]]) {
        
        if ([oldValue isKindOfClass:[NSNull class]]) {
            return [NSDictionary dictionary];
        }
        
    } else if (property.type.typeClass == [NSDate class]) {
        
        NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
        fmt.dateFormat = @"yyyy-MM-dd";
        return [fmt dateFromString:oldValue];
    }
    return oldValue;
}



@end

@implementation CellModel

+(NSDictionary *)mj_replacedKeyFromPropertyName
{
    return [super mj_replacedKeyFromPropertyName];
}
@end


@implementation BaseSectionModel

@end
